/**
 * @author LKQ
 * @date 2022/2/24 12:11
 * @description
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        solution.winnerOfGame("ABBBBBBBAAA");
    }
    public boolean winnerOfGame(String colors) {
        int n = colors.length(), a = 0, b = 0;
        char[] color = colors.toCharArray();
        for (int i = 0; i < n; i++) {
            int cnt1 = 0, cnt2 = 0;
            while (i < n && color[i] == 'A') {
                cnt1++;
                i++;
            }
            cnt1 = cnt1 > 2 ? cnt1 - 2: 0;
            while (i < n && color[i] == 'B') {
                cnt2++;
                i++;
            }
            i = i - 1;
            cnt2 = cnt2 > 2 ? cnt2 - 2: 0;
            a+= cnt1;
            b+= cnt2;
        }
        return a > b;
    }
}
